using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum PanelId
{
    MainMenu = 1001,
    CoinShop = 1002,
    Ingame = 1003,
    Pause = 1004,
    LevelComplete = 1005
}
public class UIManager : MonoSingleton<UIManager>
{
    public Dictionary<PanelId, IUIBase> panelList = new Dictionary<PanelId, IUIBase>();
    public override void Init()
    {
        base.Init();
    }
    public void CreateOrOpen(PanelId panelId)
    {
        if (!panelList.ContainsKey(panelId))
        {
            Debug.LogError("面板未在字典中");
        }
        else
        {
            panelList[panelId].Show();
        }
        panelList[panelId].Init();
    }
    public void HideOrDestroy(PanelId panelId, bool isDestroy = false)
    {
        if (panelList[panelId] != null)
            panelList[panelId].Hide();
        else
        {
            Debug.Log("当前面板为空");
        }
        if (isDestroy)
        {
            panelList.Remove(panelId);
            Destroy((UIPanel)panelList[panelId]);
        }
    }
    public void AddPanel(PanelId panelId, IUIBase panel)
    {
        if (panelList.ContainsKey(panelId))
        {
            Debug.Log("重复添加面板");
        }
        else
        {
            panelList.Add(panelId, panel);
        }
    }
}
